package org.abio.XasML.converter
{
	import flash.system.ApplicationDomain;
	import flash.utils.getQualifiedClassName;
	
	public function object2Class(obj:Object, domain:ApplicationDomain=null):Class
	{
		if(domain==null){
			domain=ApplicationDomain.currentDomain;
		}
		
		if(obj is Class){
			return obj as Class;
		}else if(obj is String){
			return domain.getDefinition(obj as String) as Class;
		}else if(getQualifiedClassName(obj)=="*"
				|| getQualifiedClassName(obj)=="void"
				|| getQualifiedClassName(obj).indexOf(".as$")!=-1){
			throw('object2Class converter error, private class defination');
		}else{
			return domain.getDefinition(getQualifiedClassName(obj)) as Class;
		}
	}
}